﻿using Microsoft.Xna.Framework;

namespace block_explorer
{
    public class Block
    {
        public const float SIZE = 1.0f;

        public enum ContentType
        {
            AIR,
            DIRT,
            STONE
        }

        ContentType mContent;
        int mLightValue;
        bool mSky;
        bool mLightSource;

        public int LightValue { get { return mLightValue; } set { mLightValue = value; } }
        public bool Sky { get { return mSky; } set { mSky = value; } }
        public bool LightSource { get { return mLightSource; } set { mLightSource = value; } }

        public Block(ContentType content)
        {
            mContent = content;
            mLightValue = 16;
        }

        public ContentType Content { get { return mContent; } set { mContent = value; } }

        public bool IsSolid() { return mContent != ContentType.AIR; }

        public static Vector3 GetCenter(Vector3 position)
        {
            return position + new Vector3(SIZE / 2.0f, SIZE / 2.0f, SIZE / 2.0f);
        }

        public static void GetContentTextureOffsetSize(ContentType content, out Vector2 offset, out Vector2 size)
        {
            //offset = Vector2.Zero;
            //size = Vector2.One;

            size = new Vector2(0.5f, 1.0f);

            if (content == ContentType.DIRT)
            {
                offset = new Vector2(0, 0);
            }
            else
            {
                offset = new Vector2(0.5f, 0.0f);
            }
        }
    }
}
